$.post(Feng.ctxPath + "/payService/getDepartment", function (data) {
    var listr = "";
    for (var i = 0; i < data.length; i++) {
        listr += '<div style="width: 20%"><span class="checkboxStyle">' +
            '<input class="checkboxClass" type="radio" value="' + data[i].department + '" name="about" id="click_' + data[i].department + '"></span>' +
            '<label for="click_' + data[i].department + '" class="labelStyle">' + data[i].department + '</label></div>';
    }
    document.getElementById('treatmentUnitBox').innerHTML = listr;
}, "json");
var windowNameIndex = parent.layer.getFrameIndex(window.name); //获取窗口索引
$("#treatmentUnitBox").on('click', '.checkboxStyle', function () {
    $(this).children().attr('checked','true');
    $(this).addClass('selection').parent().siblings().children('.checkboxStyle').removeClass('selection');
});
$("#submission").click(function () {
    var initialization = $("input[name='about']:checked").val();
    var customerId = $("#customerId").val();
    var remarks = $("#remarks").val();
    var treatmentUnitY = $("#treatmentUnitY").val();
    if (initialization == "" || initialization == null) {
        alert("请选择一个科室！");
        return;
    }
    $.ajax({
        url: Feng.ctxPath + "/customer/treatmentUnitGrade",
        type: "post",
        data: {
            "initialization": initialization,
            "customerId": customerId,
            "treatmentUnitY": treatmentUnitY,
            "remarks": remarks
        },
        success: function (data) {
            if(data==1){//修改的科室等级小于原科室的等级需要审核
                if (remarks == "" || remarks == null) {
                    alert("请填写备注！")
                    return;
                }
                var r = confirm("提交审批？");
                if (r == true) {
                    $.ajax({
                        url: Feng.ctxPath + "/customer/update_TreatmentUnitValueOne",
                        type: "post",
                        data: {
                            "initialization": initialization,
                            "customerId": customerId,
                            "treatmentUnitY": treatmentUnitY,
                            "remarks": remarks
                        },
                        success: function (data) {
                            Feng.success("提交成功!");
                            window.parent.Customer.table.refresh();
                            parent.layer.close(windowNameIndex);
                        }
                    });
                }
            }else if(data==2){ //修改的科室等级大于原科室的等级 直接修改
                var r = confirm("是否确认从["+treatmentUnitY+"]科室改成["+initialization+"]科室？");
                if (r == true) {
                    $.ajax({
                        url: Feng.ctxPath + "/customer/update_TreatmentUnitValueTwo",
                        type: "post",
                        data: {
                            "initialization": initialization,
                            "customerId": customerId,
                            "treatmentUnitY": treatmentUnitY,
                            "remarks": remarks
                        },
                        success: function (data) {
                            Feng.success("修改成功!");
                            window.parent.Customer.table.refresh();
                            parent.layer.close(windowNameIndex);
                        }
                    });
                }
            }
        }
    });
});